import router from "./index"

router .beforeEach((to,from,next) =>{
    if(to.meta.isLogin){
        var token=sessionStorage.getItem("token");
        if(token !== '' || token){
            next()
        }else{
            next({
                name:"login"
            })
        }
    }else{
        next();
    }

    // if(to.path==='/admin/login') return next();
    //     // 获取token
    // const tokenStr = window.sessionStorage.getItem('token');
    // if(!tokenStr || tokenStr!='249972068') return next('/admin/login');
    // next();
},)

// router.beforeEach((to,from,next)=>{
//   // to: 将要访问的路径
//   // from: 表示从哪个路径跳转过来
//   // next: 是一个函数，放行
//   if(to.path==='/admin/login') return next();
//       // 获取token
//       const tokenStr = window.sessionStorage.getItem('token');
//       if(!tokenStr || tokenStr!='249972068') return next('/admin/login');
//       next();
// });